from django.db import models

# Create your models here.

# 用户表
class UserLogin(models.Model):
    user_name = models.CharField(max_length=36)
    password = models.CharField(max_length=24)
    user_owner = models.CharField(max_length=4, default=0)

# 商品类型表
class GoodsType(models.Model):
    goods_type_name = models.CharField(max_length=36)
    goods_image = models.FileField(upload_to="image")


# 用户收件地址表
# class UserInfo(models.Model):
#     user_nickname = models.CharField(max_length=36)
#     user_address = models.CharField(max_length=360)
#     user_phone = models.CharField(max_length=11)
#     user_address_num = models.IntegerField()
#     userlogin = models.ForeignKey(to=UserLogin, on_delete=models.CASCADE)  # 关联用户表，一对多


# 店铺表
class Shop(models.Model):
    shop_name = models.CharField(max_length=80)
    shop_address = models.CharField(max_length=80)
    shop_descript = models.TextField(default='')
    shop_pic = models.FileField(upload_to="image", default='/static/store/img/by.jpg')
    userlogin = models.OneToOneField(to=UserLogin, on_delete=models.CASCADE)

# 商品表
class Goods(models.Model):
    goods_name = models.CharField(max_length=36)
    goods_price = models.FloatField()
    goods_count = models.IntegerField()
    goods_address = models.CharField(max_length=36)
    goods_onshelf = models.DateField()
    goods_overtime = models.DateTimeField()
    goods_image = models.FileField(upload_to="image")
    goods_weight = models.IntegerField()
    goods_text = models.CharField(max_length=512)
    goodstype = models.ForeignKey(to=GoodsType, on_delete=models.CASCADE)
    shop = models.ManyToManyField(to=Shop)


# # 购物车表
# class ShopCar(models.Model):
#     shop_count = models.IntegerField()
#     shop_sum_price = models.IntegerField()
#     userlogin = models.ForeignKey(to=UserLogin, on_delete=models.CASCADE)
#     goods = models.ManyToManyField(to=Goods)
#
#
# # 用户订单表
# class UserOrder(models.Model):
#     user_order_count = models.IntegerField()
#     user_order_sum_price = models.IntegerField()
#     user_order_stutas = models.CharField(max_length=36)
#     user_order_num = models.IntegerField()
#     userlogin = models.ForeignKey(to=UserLogin, on_delete=models.DO_NOTHING)
#     goods = models.ForeignKey(to=Goods, on_delete=models.DO_NOTHING)
#
#
# # 商家订单表
# class ShopOrder(models.Model):
#     shop_order_paytype = models.CharField(max_length=36)
#     shop_order_time = models.DateTimeField()
#     userinfo = models.ForeignKey(to=UserInfo, on_delete=models.DO_NOTHING)
#     userorder = models.OneToOneField(to=UserOrder, on_delete=models.DO_NOTHING)

